package com.woniuxy.api;

import com.woniuxy.entity.Product;
import com.woniuxy.entity.ProductDTO;
import com.woniuxy.entity.utils.ResponseEntity;
import com.woniuxy.hystrix.FallbackFactoryCommand;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @Author: 杨俊杰
 * @Description: 使用OpenFeign对远程product服务进行调用 @FeignClient("服务名")
 * @DateTime: 22/12/07/0007 10:42
 * @Component: 成都蜗牛学苑
 *
 **/

@FeignClient(value = "myh-product",fallbackFactory = FallbackFactoryCommand.class)
@RequestMapping("/product")
public interface RemoteProductServe {
    @GetMapping("/{pid}")
    ResponseEntity findOneByPid(@PathVariable("pid") Integer pid);
    @PutMapping("/")
    ResponseEntity updateProduct(@RequestBody Product product);

//    @GetMapping("/findCondition")
//    public ResponseEntity findAllByNameOrPrice(@RequestParam("name") String name,@RequestParam("minPrice") double minPrice,
//                                               @RequestParam("maxPrice") double maxPrice);
//    @GetMapping("/findCondition")
//    public ResponseEntity findAllByNameOrPrice1(@SpringQueryMap Map map);

    //解决参数过多 @SpringQueryMap + 写一个数据传输对象ProductDTO
    @GetMapping("/findCondition")
    public ResponseEntity findAllByNameOrPrice1(@SpringQueryMap ProductDTO productDTO);
}
